<%@page import="service.implement.ProjectDAO"%>
<%@page import="model.Project"%>
<%@page import="service.implement.EmployeeDAO"%>
<%@page import="model.Employee"%>
<%@page import="service.implement.TimesheetDAO"%>
<%@page import="model.Timesheet"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<%@ include file="Menu.jsp"%>
	<form action="doTimesheet" method="post" id="delete">

		<div class="panel panel-default">
			<!-- Default panel contents -->
			<div class="panel-heading">List Timesheet</div>

			<!-- Table -->
			<table class="table">

				<thead>
					<tr>
						<th>Id</th>
						<th>Employee</th>
						<th>Project</th>
						<th>Date</th>
						<th>Duration</th>
						<th>Description</th>
						<th>Activity</th>
						<th>Overtime</th>
						<th>Location</th>
					</tr>
				</thead>
				<tbody>
					<%
						ArrayList<Timesheet> list = new TimesheetDAO().getTimesheet();
						ArrayList<Employee> dsemp = new EmployeeDAO().getEmployee();
						ArrayList<Project> dspj = new ProjectDAO().getProject();
						try {
							int i = 0;
							for (Timesheet t : list) {
								for (Employee e : dsemp) {
									for (Project p : dspj) {
										if (t.getEmployeeid() == e.getId()) {
											if (p.getId() == t.getProjectid()) {
					%>
					<tr>
						<td><%=t.getId()%></td>
						<td><%=e.getName()%></td>
						<td><%=p.getNameProject()%></td>
						<td><%=t.getDate()%></td>
						<td><%=t.getDuration()%></td>
						<td><%=t.getDescription()%></td>
						<td><%=t.getActivity()%></td>
						<td><%=t.getOvertime()%></td>
						<td><%=t.getLocation()%></td>
						<td><a href="doTimesheet?checkTimesheet=<%=t.getId()%>">Edit</a></td>
						<td><input type="checkbox" id="checkTimesheet<%=i%>"
							name="checkTimesheet<%=i%>" value="<%=t.getId()%>" /></td>
					</tr>
					<%
						i++;
											}
										}
									}
								}
							}
						}

						catch (Exception e) {
							e.printStackTrace();
						}
					%>
					<input type="hidden" name="size" value="<%=list.size()%>" />
				</tbody>
			</table>
		</div>
		<input type="submit" name="do" class="submit1"
			value="Delete Timesheet"
			onclick="return confirm('Ban that su muon xoa ?');" />
	</form>

</body>
</html>